<template>
  <div>
    <el-button style="float: right; padding: 3px 0" type="text" @click="getMes">刷新</el-button>
    <el-table :data="info.mes">
      <el-table-column property="name" label="设备名称" width="auto" sortable></el-table-column>
      <el-table-column property="type" label="设备类型"></el-table-column>
      <el-table-column property="ip" label="IP地址"></el-table-column>
      <el-table-column property="ipMask" label="子网掩码"></el-table-column>
      <el-table-column property="ntpState" label="Ntp状态">
        <template slot-scope="scope">
          <el-tag
              :type="scope.row.ntpState ? 'primary' : 'danger'"
              disable-transitions>{{ scope.row.ntpState ? '是' : '否' }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column width="230" property="softwareVersion" label="软件版本"></el-table-column>
      <el-table-column width="230" property="hardwareVersion" label="硬件版本"></el-table-column>
      <el-table-column property="state" label="运行状态">
        <template slot-scope="scope">
          <el-tag
              :type="scope.row.state ? 'primary' : 'danger'"
              disable-transitions>{{ scope.row.state ? '是' : '否' }}
          </el-tag>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "MeList",
  data() {
    return {
      nodeName: '',
      info: {
        "mes": [
          {
            name: "otna",
            ntpState: true,
            ip: '192.168.12.112',
            ipMask: '255.255.255.0',
            type: 'OTN-A3',
            "softwareVersion": "v1.0.8  -2020/8/7 16:50:48",
            "hardwareVersion": "pcb_ver:1 board_type:none",
            state: true,
          },
          {
            name: "hclink",
            ntpState: true,
            ip: '192.168.1.101',
            ipMask: '255.255.255.0',
            type: 'OTN-A6',
            "softwareVersion": "v1.0.8  -2020/8/7 16:50:48",
            "hardwareVersion": "pcb_ver:1 board_type:none",
            state: false,
          },
          {
            name: "test",
            ntpState: false,
            ip: '192.168.12.112',
            ipMask: '255.255.255.0',
            type: 'OTN-A10',
            "softwareVersion": "v1.0.8  -2020/8/7 16:50:48",
            "hardwareVersion": "pcb_ver:1 board_type:none",
            state: false,
          },
        ]
      }

    }
  },
  methods: {
    getMes() {
      axios.get("/node/" + this.nodeName + "/eqs").then(
          response => {
            console.log("请求成功", response.data);
            this.$message.success("获取设备信息成功");
            this.eqs = response.data;
          },
          error => {
            console.log("失败！", error.message);
            this.$message.error(error.message);
          }
      )
    },
  },
  mounted() {
    this.$bus.$on('node-name', (data) => {
      console.log('Me - node : ', data);
      this.nodeName = data;
    })
  }

}
</script>

<style scoped>

</style>